package ipc;

public class preSolve{
	public long sizeofR;
	public long sizeofP;
	public long sizeofA;
	public double timetobuildcpt;
	
	public String toInsert(int runid){
		StringBuffer sb = new StringBuffer();
		sb.append("INSERT INTO PRESOLVE VALUES (");
		sb.append(runid);
		sb.append(", ");
		sb.append(sizeofR);
		sb.append(", ");
		sb.append(sizeofP);
		sb.append(", ");
		sb.append(sizeofA);
		sb.append(", ");
		sb.append(timetobuildcpt);
		sb.append(")");
		
		return sb.toString();
	}
	
	@Override
	public String toString() {
		return "preSolve [sizeofR=" + this.sizeofR + ", sizeofP="
				+ this.sizeofP + ", sizeofA=" + this.sizeofA
				+ ", timetobuildcpt=" + this.timetobuildcpt + "]";
	}

	public preSolve(long sizeofR, long sizeofP, long sizeofA, double timetobuildcpt) {
		super();
		this.sizeofR = sizeofR;
		this.sizeofP = sizeofP;
		this.sizeofA = sizeofA;
		this.timetobuildcpt = timetobuildcpt;
	}

	public preSolve() {
		this.sizeofR = 0;
		this.sizeofP = 0;
		this.sizeofA = 0;
		this.timetobuildcpt = 0;
	}

	public void finishUp(int nRuns) {
		sizeofA /= nRuns;
		sizeofP /= nRuns;
		sizeofR /= nRuns;
		timetobuildcpt /= nRuns;			
	}

	public void addpreSolve(preSolve ps) {
		sizeofA += ps.sizeofA;
		sizeofP += ps.sizeofP;
		sizeofR += ps.sizeofR;
		timetobuildcpt += ps.timetobuildcpt;			
	}
	
}
